package net.brokenroad.gamma.gui;

import javax.swing.*;
import net.brokenroad.gamma.net.*;
import net.brokenroad.gamma.tools.*;

public class SessionConnectFrame
{

	JFrame frame;

	JTextField hostname, port;

	public JButton accept, cancel;

	ConnectionInfo cInfo;

	public SessionConnectFrame(PacketTester pt)
	{
		frame = new JFrame("Connect");
		frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.PAGE_AXIS));

		hostname = new JTextField("localhost");
		port = new JTextField("1125");

		accept = new JButton("Accept");
		accept.addActionListener(pt);
		cancel = new JButton("Cancel");
		cancel.addActionListener(pt);
		frame.add(hostname);
		frame.add(port);
		frame.add(accept);
		frame.setSize(300, 400);
		frame.setVisible(true);

	}

	public void close()
	{
		frame.setVisible(false);
	}

	/**
	 * @return the cInfo
	 */
	public ConnectionInfo getCInfo()
	{
		return new ConnectionInfo(hostname.getText(), Integer.parseInt(port
		    .getText()));
	}
}
